center a video horizontally

65

/*option 1:this makes the video responsive*/
.videoDiv
{
    width: 70%; /*or whatever % you prefer*/
    margin: 0 auto;
    display: block;
}

/* option 2* does not make the video responsive*/

.videoDiv{
  margin:0 auto;
  display: block;
}  
<div class="videoDiv">
  <video width="100%" controls>
    <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
    <source src="https://www.w3schools.com/html/mov_bbb.ogg" type="video/ogg">
  Your browser does not support the video tag.
  </video>
</div>

Comments

Submit
0 Comments